//
//  TestBoardFactory.m
//  INFSWA02
//
//  Created by Justin van Grootveld on 10/24/11.
//  Copyright (c) 2011 Justinform. All rights reserved.
//

#import "TestBoardFactory.h"
#import "Board.h"
#import "Piece.h"
#import "KingPieceFactory.h"
#import "HagPieceFactory.h"
#import "MagePieceFactory.h"
#import "ArcherPieceFactory.h"
#import "TrebuchetPieceFactory.h"
#import "TowerPieceFactory.h"

@implementation TestBoardFactory

+ (Board *)createBoardWithPlayer1:(NSString *)player1 andPlayer2:(NSString *)player2
{
    Board *board = [[Board alloc] initWithS:8];
    [board initPlayersWithNames:player1 andPlayer2:player2];
    
    //player 1
    Player *p1 = board.player1;
    
    //1st row
    [board setPiece:[KingPieceFactory createPieceForPlayer:p1] atLocationX:0 andY:0];
    
    //2nd row
    [board setPiece:[TowerPieceFactory createPieceForPlayer:p1] atLocationX:0 andY:1];
    [board setPiece:[TowerPieceFactory createPieceForPlayer:p1] atLocationX:1 andY:0];
    
    //3th row
    [board setPiece:[ArcherPieceFactory createPieceForPlayer:p1] atLocationX:0 andY:2];
    [board setPiece:[TrebuchetPieceFactory createPieceForPlayer:p1] atLocationX:1 andY:1];
    [board setPiece:[ArcherPieceFactory createPieceForPlayer:p1] atLocationX:2 andY:0];
    
    //4th row
    [board setPiece:[MagePieceFactory createPieceForPlayer:p1] atLocationX:0 andY:3];
    [board setPiece:[ArcherPieceFactory createPieceForPlayer:p1] atLocationX:1 andY:2];
    [board setPiece:[ArcherPieceFactory createPieceForPlayer:p1] atLocationX:2 andY:1];
    [board setPiece:[MagePieceFactory createPieceForPlayer:p1] atLocationX:3 andY:0];
    
    //5th row
    [board setPiece:[MagePieceFactory createPieceForPlayer:p1] atLocationX:0 andY:4];
    [board setPiece:[HagPieceFactory createPieceForPlayer:p1] atLocationX:1 andY:3];
    [board setPiece:[TrebuchetPieceFactory createPieceForPlayer:p1] atLocationX:2 andY:2];
    [board setPiece:[HagPieceFactory createPieceForPlayer:p1] atLocationX:3 andY:1];
    [board setPiece:[MagePieceFactory createPieceForPlayer:p1] atLocationX:4 andY:0];
    
    //Player 2
    Player *p2 = board.player2;
    
    //1st row
    [board setPiece:[KingPieceFactory createPieceForPlayer:p2] atLocationX:2 andY:3];
    
    //2nd row
    [board setPiece:[TowerPieceFactory createPieceForPlayer:p2] atLocationX:6 andY:7];
    [board setPiece:[TowerPieceFactory createPieceForPlayer:p2] atLocationX:7 andY:6];
    
    //3th row
    [board setPiece:[ArcherPieceFactory createPieceForPlayer:p2] atLocationX:5 andY:7];
    [board setPiece:[TrebuchetPieceFactory createPieceForPlayer:p2] atLocationX:6 andY:6];
    [board setPiece:[ArcherPieceFactory createPieceForPlayer:p2] atLocationX:7 andY:5];
    
    //4th row
    [board setPiece:[MagePieceFactory createPieceForPlayer:p2] atLocationX:4 andY:7];
    [board setPiece:[ArcherPieceFactory createPieceForPlayer:p2] atLocationX:5 andY:6];
    [board setPiece:[ArcherPieceFactory createPieceForPlayer:p2] atLocationX:6 andY:5];
    [board setPiece:[MagePieceFactory createPieceForPlayer:p2] atLocationX:7 andY:4];
    
    //5th row
    [board setPiece:[MagePieceFactory createPieceForPlayer:p2] atLocationX:3 andY:7];
    [board setPiece:[HagPieceFactory createPieceForPlayer:p2] atLocationX:4 andY:6];
    [board setPiece:[TrebuchetPieceFactory createPieceForPlayer:p2] atLocationX:5 andY:5];
    [board setPiece:[HagPieceFactory createPieceForPlayer:p2] atLocationX:6 andY:4];
    [board setPiece:[MagePieceFactory createPieceForPlayer:p2] atLocationX:7 andY:3];
    
    return board;
}

@end
